<template>
  <div class="login">
    <div class="box">
      <div class="bg">
        <img src="./images/user-bg.png" alt="">
      </div>
      <div class="content">
        <img class="logo-image" :src="require('./images/tianmao.png')" alt="">
        <div class="user-tips">登录</div>
        <el-form label-position="left" :model="model" ref="login" :rules="rules" size="small">
          <el-form-item label="用户账号" prop="account">
            <el-input v-model.trim="model.account" autocomplete="on" class="form-input" @keyup.enter.native="toLogin"></el-input>
          </el-form-item>
          <el-form-item label="用户密码" prop="password">
            <el-input type="password" v-model="model.password" autocomplete="on" show-password class="form-input" @keyup.enter.native="toLogin" maxlength="20"></el-input>
          </el-form-item>
        </el-form>
        <el-button type="success" round class="sure-btn" @click="toLogin">
          <div class="sure-name">登录</div>
        </el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    const validateAccount = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('用户账号不能为空'))
      } else {
        callback()
      }
    }
    const validatePass = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('用户密码不能为空'))
      } else if (value.length < 6) {
        callback(new Error('不能少于6位数'))
      } else {
        callback()
      }
    }
    return {
      model: {
        account: '',
        password: ''
      },
      rules: {
        account: [{ validator: validateAccount, trigger: ['blur'] }],
        password: [{ validator: validatePass, trigger: ['blur'] }]
      }
    }
  },
  created () {

  },
  methods: {
    toLogin () {
      this.$nextTick(() => {
        this.$refs.login.validate((valid) => {
          if (valid) {

          }
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>
$bg:#f4f7fa;

.login {
  min-height: 100%;
  min-height: 100vh;
  width: 100%;
  background-color: $bg;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  .box {
    width:1200px;
    min-height:550px;
    background:rgba(255,255,255,1);
    border-radius:10px;
    box-shadow: #ccc 0px 0px 20px;
    display: flex;
    align-items: flex-start;
    .bg {
      flex: 1;
      padding: 40px 60px 40px 40px;
      img {
        width: 100%;
        height: auto;
      }
    }
    .content {
      padding: 40px 60px 20px;
      width: 450px;
      text-align: center;
      .logo-image {
        width: 126px;
        height: auto;
        margin-bottom: 20px;
      }
      .user-tips {
        text-align: left;
        margin: 19px 0 48px;
        font-size: 24px;
        font-weight: bold;
        color: rgba(100, 188, 255, 1);
      }
      /deep/ .form-input {
        text-align: left;
        .el-input__inner {
          border-top: 0 !important;
          border-left: 0 !important;
          border-right: 0 !important;
          border-radius: 0 !important;
        }
      }
      .suffix-from {
        /deep/ .el-input__inner {
          width: 280px;
        }
        .getcode {
          position: absolute;
          right: 0;
          bottom: 0;
          margin-left: 20px;
          width: 124px;
          border: 1px solid #64bcff;
          border-radius: 4px;
          font-weight: 400;
          color: #64bcff;
        }
      }
      .sure-btn {
        margin-top: 37px;
        width: 192px;
        height: 44px;
        background: rgba(100, 188, 255, 1);
        border-color: rgba(100, 188, 255, 1);
        box-shadow: 0px 6px 6px 0px rgba(57, 160, 255, 0.2);
        border-radius: 22px;
        .sure-name {
          font-size: 16px;
          font-weight: 400;
          color: rgba(255, 255, 255, 1);
          letter-spacing: 16px;
          text-indent: 16px;
        }
      }
    }
  }
}
</style>
